<template>
  <div class="home-user-count">
    <div class="count-wrapper">
      <div class="start">
        当前已经为广大用户完成<span class="count-num">{{num.toLocaleString()}}</span>份回收
      </div>
      <router-link class="count-btn" to="/">立即使用</router-link>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      num: 0,
      target: 1135877437,
    };
  },
  methods: {
    grow() {
      this.num += Math.round(this.target / 63);
      this.num = this.num < this.target ? this.num : this.target;
      if (this.num < this.target) {
        setTimeout(this.grow, 16);
      }
    },
  },
  mounted() {
    this.grow();
  },
};
</script>

<style lang="scss" scoped>
.count-wrapper {
  width: 1000px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #ddd;
  padding: 47px 20px;
  box-sizing: border-box;
}
.start {
  color: #999;
  font-size: 14px;
}
a {
  text-decoration: none;
  color: white;
}
.count-btn {
  padding: 0 41px;
  line-height: 46px;
  height: 46px;
  font-size: 18px;
  background-color: #80c200;
  border: 1px solid #80c200;
  border-radius: 7px;
}
.count-num {
  color: #58a6e7;
  font-size: 30px;
  margin-right: 5px;
}
</style>
